"use strict"

let 
    Koa = require('koa'),
    bodyParser = require('koa-bodyparser'),
    staticRes = require('koa-static'),
    tempalating = require('./templating'),
    controller = require('./controllers'),
    model = require('./models'),
    session = require('./session'),
    port = 9090;


let app = new Koa();

app.use(staticRes(__dirname,'/static/'));

app.use(session(app));

app.use(bodyParser());

app.use(tempalating);

;(async (ctx,next)=>{
    console.log('正在初始化数据');
    // await model.sync();
})();

app.use(controller());

app.listen(port,()=>{
    console.log(`http://localhost:${port}`);
})